package com.jinbooks.persistence.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinbooks.entity.channel.Channel;
import com.jinbooks.entity.channel.dto.ChannelPageDto;
import com.jinbooks.entity.channel.vo.ChannelVo;
import com.jinbooks.persistence.mapper.ChannelMapper;
import com.jinbooks.persistence.service.ChannelService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 渠道服务实现
 *
 * @author lingma
 */
@Service
@RequiredArgsConstructor
public class ChannelServiceImpl implements ChannelService {
    private final ChannelMapper baseMapper;

    @Override
    public Page<ChannelVo> pageList(ChannelPageDto dto) {
        return baseMapper.channelPageList(dto.build(), dto);
    }

    @Override
    public ChannelVo getById(String id, String workspaceId) {
        return baseMapper.getChannelById(id, workspaceId);
    }

    @Override
    public Boolean save(Channel dto) {
        return baseMapper.insert(dto) > 0;
    }

    @Override
    public Boolean update(Channel dto) {
        return baseMapper.updateById(dto) > 0;
    }

    @Override
    public Boolean deleteByIds(List<String> ids) {
        return baseMapper.deleteByIds(ids) > 0;
    }
}